﻿// See https://aka.ms/new-console-template for more information

using System.Text;
using util_c_sharp.util;

UtilMqtt.InitMqttClient(e =>
{
    Console.WriteLine("消息通知");
    Console.WriteLine($"+ Topic = {e.ApplicationMessage.Topic}");
    Console.WriteLine($"+ Payload = {Encoding.UTF8.GetString(e.ApplicationMessage.Payload)}");
    Console.WriteLine($"+ QoS = {e.ApplicationMessage.QualityOfServiceLevel}");
    Console.WriteLine($"+ Retain = {e.ApplicationMessage.Retain}");
    Console.WriteLine();
});

while (true)
{
    string? str = Console.ReadLine();
    UtilMqtt.PubMsg("demo_data", str ?? "test 发送内容");
}
